import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import eslintPlugin from 'vite-plugin-eslint'
import vuejsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
const { resolve } = require('path')
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({ // 配置按需加载
      resolvers: [
        AntDesignVueResolver({ // 配置按需加载
          importStyle: 'less'
        })
      ]
    }),
    eslintPlugin({ // 配置eslint插件
    }),
    vuejsx({
    })
  ],
  define: {
    'process.env': {
      BASE_URL: '/'
    }
  },
  resolve: {
    alias: [ // 配置别名
      {
        find: '@',
        replacement: resolve(__dirname, 'src')
      }
    ]
  },
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `@import "${resolve(__dirname, 'src/assets/less/global.less')}";`, // 配置全局less 变量
        javascriptEnabled: true
        // modifyVars: {
        //   'primary-color': '#722ed1' // 配置主题色
        // }
      }
    }
  }
})
